#pragma once

#include "Game/Process/RenderProcess.h"
#include "Render/Texture/Picture2DTexture.h"
#include "Render/Texture/RenderTarget.h"
#include "Render/Tradition/RHIRenderPass.h"
#include "Render/Tradition/GraphicsPipeline.h"
#include "Render/Texture/ColorRenderTarget.h"
#include "Render/Texture/CubemapTexture.h"
#include "Render/Texture/DepthRenderTarget.h"
#include "Render/Shader/RHIDescriptor.h"
#include "Render/Tradition/RHIFramebuffer.h"
#include "LocalEntity.h"


class SsrProcess : public RenderProcess
{
	DECLARE_PROCESS(SsrProcess)

	struct Ubo {
		glm::mat4 proj;
		glm::mat4 view;
		glm::mat4 invProj;
		glm::mat4 invView;
		glm::mat4 projViewInverse;
	};

	struct PushConstants {
		float rayStep;
		float distanceBias;
		float samplingCoefficient;

		int32 iterationCount;
		int32 sampleCount;

		int32 enableSSR;
		int32 isSamplingEnabled;
		int32 isExponentialStepEnabled;
		int32 isAdaptiveStepEnabled;
		int32 isBinarySearchEnabled;
		int32 debugDraw;
	};

public:

	bool mEnableSSR;
	bool mIsSamplingEnabled;
	bool mIsExponentialStepEnabled;
	bool mIsAdaptiveStepEnabled;
	bool mIsBinarySearchEnabled;
	bool mDebugDraw;

	PushConstants mPushConstants;

protected:

	virtual void OnInit() override;

	virtual void OnTick(float deltaTime) override;

	virtual void OnResize() override;

protected:


	RefCountPtr<RHIBuffer> mUboBuffer;

	RefCountPtr<RHISampler> mCommonSampler;

	DescriptorMask mDescriptorMask;

	RefCountPtr<RHIDescriptor> mDescriptor;

	RefCountPtr<GraphicsPipeline> mPipeline;

	RefCountPtr<RHIRenderPass> mRenderPass;

	RefCountPtr<RHIFrameBuffer> mFrameBuffer;

	RefCountPtr<ColorRenderTarget> mColorRenderTarget;

};

